package main

import "fmt"

// 切片 map 指针 使用必须先make 分配内存空间
type stu struct {
	name string
	age  int
	sli  []int
	ma   map[string]string
	ptr  *int
}

func main() {
	var s1 stu
	fmt.Println(s1)
	s1.name = "jack"
	s1.age = 18

	fmt.Println(s1)
	if s1.sli == nil {
		fmt.Println("sli is nis")
	}

	if s1.ma == nil {
		fmt.Println("ma is nis")
	}

	if s1.ptr == nil {
		fmt.Println("ptr is nis")
	}

	// init slice
	s1.sli = make([]int, 2)
	s1.sli[0] = 12
	s1.sli[1] = 23

	fmt.Println(s1)

	// init map
	s1.ma = make(map[string]string)
	s1.ma["test"] = "test01"

	fmt.Println(s1)

	s1.ptr = new(int)

	n := 10
	s1.ptr = &n
	fmt.Println(s1)
	fmt.Println(*(s1.ptr))

}
